package org.example.ExperimentTwo;

import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class EmileRegex {
    public static void main(String[] args) {
        String email="";
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入email：");
        email=sc.next();
//        正则表达式
        String emailRegex = "^[a-zA-Z0-9_+&*-]+(?:\\.[a-zA-Z0-9_+&*-]+)*@(?:[a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,7}$";
//创建匹配模式
        Pattern pattern=Pattern.compile(emailRegex);
//        创建Match对象
        Matcher matcher=pattern.matcher(email);
        if(matcher.matches()){
            System.out.println("邮箱地址正确");
        }else{
            System.out.println("邮箱地址不正确");
        }
    }
}
